Public Class frmOptions
    Dim ChangedBkmPath As Boolean = False
    Dim HideWarning As Boolean
    Private Sub frmOptions_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        chkEnableDblClick.Checked = My.Settings.EnableDoubleClick
        chkWarnOnDelete.Checked = My.Settings.WarnOnDelete
        nudRecentBookmarks.Value = My.Settings.RecentBookmarksNumber
        chkCloseTray.Checked = My.Settings.CloseToTray
        chkMinTray.Checked = My.Settings.MinToTray
        chkEnableTray.Checked = My.Settings.EnableTray
        chkPrefetchBookmarks.Checked = My.Settings.PrefetchBookmarks
        chkUpdates.Checked = My.Settings.CheckForUpdates
        HideWarning = True
        WarnAboutExperimentalFeatures(HideWarning)
        HideWarning = False
        If My.Settings.LaunchOnDoubleClick = True Then
            rdoOpenBookmark.Checked = True
        Else : rdoPreviewBookmark.Checked = True
        End If
        txtFolder.Text = FavoritesFolder
    End Sub

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        My.Settings.EnableDoubleClick = chkEnableDblClick.Checked
        My.Settings.LaunchOnDoubleClick = rdoOpenBookmark.Checked
        My.Settings.WarnOnDelete = chkWarnOnDelete.Checked
        My.Settings.RecentBookmarksNumber = nudRecentBookmarks.Value
        My.Settings.BookmarkPath = txtFolder.Text
        My.Settings.CloseToTray = chkCloseTray.Checked
        My.Settings.MinToTray = chkMinTray.Checked
        My.Settings.EnableTray = chkEnableTray.Checked
        My.Settings.PrefetchBookmarks = chkPrefetchBookmarks.Checked
        My.Settings.CheckForUpdates = chkUpdates.Checked
        My.Settings.EnableExperimentalFeatures = chkExperimental.Checked
        frmMain.FindDeadBookmarksToolStripMenuItem.Visible = My.Settings.EnableExperimentalFeatures
        chkMinTray.Enabled = chkEnableTray.Checked : chkCloseTray.Enabled = chkEnableTray.Checked
        If ChangedBkmPath = True Then
            FavoritesFolder = My.Settings.BookmarkPath & "\"
            AddToRecentMenu(frmMain.RecentToolStripMenuItem)
        End If
        Me.Close()
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.Close()
    End Sub

    Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click
        If fldrBrowse.ShowDialog() = Windows.Forms.DialogResult.OK Then
            txtFolder.Text = fldrBrowse.SelectedPath
            ChangedBkmPath = True
        End If
    End Sub

    Private Sub chkEnableTray_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkEnableTray.CheckedChanged
        chkMinTray.Enabled = chkEnableTray.Checked : chkCloseTray.Enabled = chkEnableTray.Checked
    End Sub

    Private Sub chkExperimental_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkExperimental.CheckedChanged
        WarnAboutExperimentalFeatures(HideWarning)
    End Sub
    Sub WarnAboutExperimentalFeatures(ByVal Silent As Boolean)
        If Silent = False Then
            Select Case chkExperimental.Checked
                Case True
                    MessageBox.Show("Experimental features are NOT guaranteed to work under any conditions.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            End Select
        End If
    End Sub
End Class